﻿using ShopFine.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ShopFine
{
    public partial class CategoryList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string cateID = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(cateID))
                {
                    LoadSubCategories(cateID);
                }
            }
        }

        private void LoadSubCategories(string cateID)
        {
            var category = new CategoryDAO().GetCategoryByID(Convert.ToInt32(cateID));
            titleCategory.Text = category == null ? "N/A" : category.Name;
            var listSubCategory = new SubCategoryDAO().GetSubCategoriesByCategoryID(Convert.ToInt32(cateID));
            rptSubCategory.DataSource = listSubCategory;
            rptSubCategory.DataBind();
        }
    }
}